package _0811;

import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        String str = "0123456789abcdefghijklmnopqrstuvwxyz" +
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random ra = new Random();
        String code = "";
        for (int i = 0; i < 4; i++) {
            int a = ra.nextInt(str.length());
            char b = str.charAt(a);
            code = code + b;
        }
        System.out.println("验证码:" + code);
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入验证码");
        String input = sc.next();
        if (code.equals(input)) {
            System.out.println("验证码正确");
        } else {
            System.out.println("验证码错误");
        }
    }
}
